from direct.showbase.ShowBase import ShowBase
from Tkinter import *
import Tkinter
import tkFileDialog
import tkMessageBox

class MyApp(ShowBase):

    def __init__(self):
        ShowBase.__init__(self)

        # Panda3D setup -------------------------------------
        self.Defiant=self.loader.loadModel("defiant.x")
        self.Defiant.reparentTo(self.render)

        self.taskMgr.add(self.CameraControl,"CameraControl") 
        self.taskMgr.add(self.KeyboardControl,"KeyboardControl")

        self.accept("a",self.AKey) # ------------------------

        # GUI setup
        root=Tkinter.Tk()
        root.withdraw()     
        self.OpenAddress=tkFileDialog.askopenfilename()
        tkMessageBox.showinfo("File path", self.OpenAddress)
        root.destroy()
        
    def AKey(self):
        self.Defiant.setPos(0,self.Defiant.getY(),self.Defiant.getZ()+1)

    def CameraControl(self,task):
        # Camera control code here
        #self.camera.setPos(self.Defiant.getX(),self.Defiant.getY()-5,self.Defiant.getZ())
        #self.camera.lookAt(self.Defiant)

        return task.cont

    def KeyboardControl(self,task):
        #Keyboard control code here
        self.Defiant.setPos(0,self.Defiant.getY()+1,self.Defiant.getZ())

        return task.cont

app=MyApp()
app.run()
